<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;

class CommonController extends Controller
{
    //图片上传
	public function upload()
	{
		$file = Input::file('file');
		if ($file->isValid()) {//检查上传文件是否有效
			$extension = $file->getClientOriginalExtension();	//上传文件的后缀
			$newName = date('YmdHis') . mt_rand(100, 999) . '.' . $extension;		//新的名称
			$file->move(base_path() . '/uploads' , $newName);			//blog/uploads/
			$filePath = 'uploads/' . $newName;
			return $filePath;
		}
	}
}
